package com.zmytest.one2one;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created on 2018/12/24.
 *
 * @author zhangmingyu
 */
@RestController
@RequestMapping("/one2one")
public class TestController {

    @Autowired
    private IdentityCardRepository cardRepository;
    @Autowired
    private UserRepository userRepository;

    @GetMapping("/create")
    public void test(){

        IdentityCard identityCard = new IdentityCard();
        identityCard.setNumber("asdjfsljl");
        IdentityCard result = cardRepository.saveAndFlush(identityCard);

        User user = new User();
        user.setName("zmytest");
//        user.setIdentityCardId(result.getId());
        user.setIdentityCard(result);
        User user1 = userRepository.saveAndFlush(user);

        System.out.println("result :"+user1);
    }
}
